package com.eclipse.e0112_io.字节流字符流;

import java.io.*;

public class FileOutputStreamTest {
	public static void main(String[] args){
		//1创建被操作文件对象
		File file = new File("/Users/liuzhuangzhuang/Desktop/io/a.txt");
		FileOutputStream fos=null;
		try {
			
			
			//2创建流对象
			fos=new FileOutputStream(file,true);
			
			//3准备数据
			String str="好好学习Java";
			byte[] words = str.getBytes();
			
			//使用流写入
			fos.write(words);
			
			
			
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			System.out.println("文件更新时出错！");
			e.printStackTrace();
		}finally{
			try {
				if(fos!=null){
					fos.close();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}
